package com.llh.uua.api

import com.llh.uua.model.dto.AuthToken
import com.llh.uua.service.AccountService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 *
 *
 * Created At 2021/3/21 14:47
 * @author llh
 */
@RestController
@RequestMapping("authorize")
class AuthAPI {
    @Autowired
    private lateinit var accountService: AccountService

    @GetMapping("hello")
    fun hello(): String {
        return "hello"
    }

    @PostMapping("/jwt/login")
    fun login(@RequestBody login: LoginDto): AuthToken {
        return accountService.login(login.username, login.password)
    }
}

data class LoginDto(
    val username: String,
    val password: String,
)